﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yto.Common.Dependency;

namespace Yto.EF.DbCtx
{
    public class DbResolver : IDbResolver, ITransient
    {
        private ICtnResolver _ctnResolver;

        public DbResolver(ICtnResolver ctnResolver)
        {
            _ctnResolver = ctnResolver;
        }

        public void Realse(object obj)
        {
            _ctnResolver.Realse(obj);
        }

        public T Resolver<T>(string connstring) where T : DbContext
        {
            return _ctnResolver.Resolver<T>(new
            {
                nameOrConnectionString = connstring
            });
        }
    }
}
